package com.bbyb.operating.examination.service.impl;

import com.bbyb.operating.examination.mapper.RoleMapper;
import com.bbyb.operating.examination.model.po.Role;
import com.bbyb.operating.examination.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceimpl implements RoleService {
    @Autowired
    RoleMapper roleMapper;

    @Override
    public String addRole(Role role) {
        if(roleMapper.insert(role)==1){
            return null;
        }
        return "保存用户信息失败";
    }

    @Override
    public String deleteByPrimaryKey(Integer id) {
        if(roleMapper.deleteByPrimaryKey(id)==1){
            return null;
        }

        return "失败";
    }

    @Override
    public String updateByPrimaryKey(Role role) {
        if(roleMapper.updateByPrimaryKey(role)==1){
            return null;
        }
        return "失败";
    }

    @Override
    public List<Role> selectAll() {
        List<Role> roleList = roleMapper.selectAll();
        if(roleList!=null){
            return roleList;
        }
        return null;
    }

    @Override
    public Role selectByPrimaryKey(Integer id) {
        if(roleMapper.selectByPrimaryKey(id)!=null){
            return roleMapper.selectByPrimaryKey(id);
        }
        return null;
    }


}
